﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;

namespace Flare.Pages.ITContract
{
    public partial class Edit : UserControl, ITypicalPage
    {
        public string name
        {
            get { return "Редактирование"; }
        }

        int id;
        public Edit(int ct_id)
        {
            this.DataContext = new DB.contract_lists().Details(ct_id);
            InitializeComponent();
            id = ct_id;
        }

        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            var data = new Flare.DB.Entity.Contract.contract_list()
            {
                id_contract =id,
                id_service = (int?)Service.SelectedValue,
                id_provider = (int?)Provider.SelectedValue,
                id_department = (int?)Department.SelectedValue,
                contract_number = Contractnumber.Text,
                contract_description = Contractdescription.Text            
            };

            try
            {
                new DB.contract_lists().Edit(data);
            }
            catch (Exception ex)
            {
                glob.kernel.ShowNotice(ex.Message);
            }

        }
    }
}
